package by.msokoloff.javaweb2015.webapp.utils.renderer;

import org.apache.wicket.markup.html.form.IChoiceRenderer;

import by.msokoloff.javaweb2015.datamodel.Country;

public class CountryChoiceRenderer implements IChoiceRenderer<Country> {

	public static CountryChoiceRenderer INSTANCE = new CountryChoiceRenderer();

	private CountryChoiceRenderer() {
		super();
	}

	@Override
	public Object getDisplayValue(Country country) {
		if (country.getId() != null) {
			return country.getName();
		} else {
			return "All countries";
		}

	}

	@Override
	public String getIdValue(Country country, int index) {
		if (country.getId() != null) {
			return country.getId().toString();
		} else {
			return "0";
		}
	}

}
